package com.rd.student.wulian.wanggaobo.day0802;

abstract class Animal {
    abstract void voice();
}

class Cat extends Animal {
    @Override
    void voice() {
        System.out.println("Cat cry");
    }
}

class Pig extends Animal {
    @Override
    void voice() {
        System.out.println("Pig cry");
    }
}

class Dog extends Animal {
    @Override
    void voice() {
        System.out.println("Dog cry");
    }
}

class Store {
    public static Animal getInstance(String animal) {
        if (animal.equals("dog")) {
            return new Dog();
        } else if (animal.equals("pig")) {
            return new Pig();
        } else {
            return new Cat();
        }
    }
}